//
// Created by denglibin on 2021/6/2.
//

#include "draw.h"
#include "main_scene.h"
#include "sub_scene.h"
static MainScene * mainScene = NULL;
static SubScene * subScene = NULL;
/**
 * 场景绘制
 * @param gameWindow
 */
static void drawScene(GameWindow* gameWindow);
/**
 * 主场景
 * @param gameWindow
 */
static void drawMainScene(GameWindow* gameWindow);
/**
 * sub场景
 * @param gameWindow
 */
static void drawSubScene(GameWindow* gameWindow);
/**
 * 窗口绘制
 * @param gameWindow
 */
void draw(GameWindow* gameWindow){
    drawScene(gameWindow);
}

void drawScene(GameWindow* gameWindow){
    switch (gameWindow->scene_index) {
        case 0:
            drawMainScene(gameWindow);
            break;
        case 1:
            drawSubScene(gameWindow);
            break;
        default:
            break;
    }
}

void drawMainScene(GameWindow* gameWindow){
    if(mainScene == NULL){
        mainScene = MainSceneCreate(gameWindow);
    }
    MainSceneDraw(mainScene);
}

void drawSubScene(GameWindow* gameWindow){
    if(subScene == NULL){
        subScene = SubSceneCreate(gameWindow);
    }
    SubSceneDraw(subScene);
}